< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03020201.xhp

(section: get) (bookmark: bm_id3154927)
Get statement

Get ステートメント

Get Statement [Runtime]
Get ステートメント[実行時](hd_id3154927.1)

Reads a record from a relative file, or a sequence of bytes from a binary file, into a variable.
相対編成ファイルのレコードないし、バイナリファイルのバイトシーケンスを読み取って、変数に代入します。(par_id3145069.2)

(/section: get)

See also: PUT Statement
次も参照してください: PUT ステートメント(par_id3154346.3)

Syntax:
構文:(hd_id3150358.4)

Get [#] FileNumber As Integer, [Position], Variable
Get [#] FileNumber As Integer, [Position], Variable (par_id3150792.5)

Parameters:
パラメータ:(hd_id3154138.6)

FileNumber: Any integer expression that determines the file number.
FileNumber:ファイル番号を指定する整数表式。(par_id3150448.7)

Position: For files opened in Random mode, Position is the number of the record that you want to read.
Position: Random モードでオープンしたファイルの場合、読み取るレコードの番号を、この Position に指定します。(par_id3154684.8)

For files opened in Binary mode, Position is the byte position in the file where the reading starts.
Binary モードでオープンしたファイルの場合、ファイル内で読み取りを開始するバイト位置を、この Position に指定します。(par_id3153768.9)

If Position is omitted, the current position or the current data record of the file is used.
Position の指定を省略すると、ファイルの現在の位置ないし現在のデータレコードが使用されます。(par_id3147319.10)

Variable: Name of the variable to be read. With the exception of object variables, you can use any variable type.
Variable:データを読み込む変数の名前。この変数には、オブジェクト変数を除いた、任意の変数型を使用できます。(par_id3149484.11)

Example:
例:(hd_id3153144.12)

Sub ExampleRandomAccess
Sub ExampleRandomAccess(par_id3159154.13)

Dim iNumber As Integer
Dim iNumber As Integer(par_id3153188.14)

Dim sText As Variant REM Must be a variant
Dim sText As Variant REM バリアント型変数が必要(par_id3155307.15)

Dim aFile As String
Dim aFile As String(par_id3152577.16)

aFile = "c:\data.txt"
aFile = "c:\data.txt"(par_id3153726.17)

iNumber = Freefile
iNumber = Freefile(par_id3154490.19)

Open aFile For Random As #iNumber Len=32
Open aFile For Random As #iNumber Len=32(par_id3150418.20)

Seek #iNumber,1 REM Position at beginning
Seek #iNumber,1 REM 開始位置(par_id3149411.21)

Put #iNumber,, "This is the first line of text" REM Fill line with text
Put #iNumber,, "ここはテキストの始めの行です。" REM テキストで行を埋める(par_id3153158.22)

Put #iNumber,, "This is the second line of text"
Put #iNumber,, "This is the second line of text"(par_id3148457.23)

Put #iNumber,, "This is the third line of text"
Put #iNumber,, "This is the third line of text"(par_id3150715.24)

Seek #iNumber,2
Seek #iNumber,2(par_id3153836.25)

Get #iNumber,,sText
Get #iNumber,,sText(par_id3150327.26)

Print sText
Print sText(par_id3153707.27)

Close #iNumber
Close #iNumber(par_id3153764.28)

iNumber = Freefile
iNumber = Freefile(par_id3153715.30)

Open aFile For Random As #iNumber Len=32
Open aFile For Random As #iNumber Len=32(par_id3154256.31)

Get #iNumber,2,sText
Get #iNumber,2,sText(par_id3147340.32)

Put #iNumber,,"This is a new text"
Put #iNumber,,"This is a new text"(par_id3155938.33)

Get #iNumber,1,sText
Get #iNumber,1,sText(par_id3155959.34)

Get #iNumber,2,sText
Get #iNumber,2,sText(par_id3147361.35)

Put #iNumber,20,"This is the text in record 20"
Put #iNumber,20,"This is the text in record 20"(par_id3146916.36)

Print Lof(#iNumber)
Print Lof(#iNumber)(par_id3149259.37)

Close #iNumber
Close #iNumber(par_id3153790.38)

end sub
end sub(par_id3155606.40)


< Prev / Next >